package com.wfh.parse;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import java.util.List;


import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.wfh.bean.BannerBean;
import com.wfh.bean.ShopBean;


public class T_Shops implements TransForm{
	
	public List<ShopBean> pareseJsonArray(String json){
		List<ShopBean> list=new ArrayList<ShopBean>();
		try {
			JSONObject jsonObject = new JSONObject(json);
			JSONArray arr=jsonObject.getJSONArray("shops");
			for(int i=0;i<arr.length();i++){
				ShopBean bean=new ShopBean();
				bean.setShop_id(arr.getJSONObject(i).getString("shop_id"));
				bean.setShop_name(arr.getJSONObject(i).getString("shop_name"));
				bean.setShop_address(arr.getJSONObject(i).getString("shop_address")==null?"":arr.getJSONObject(i).getString("shop_address"));
				bean.setShop_person(arr.getJSONObject(i).getString("shop_person")==null?"":arr.getJSONObject(i).getString("shop_person"));
				bean.setShop_phone(arr.getJSONObject(i).getString("shop_phone")==null?"":arr.getJSONObject(i).getString("shop_phone"));
				bean.setShop_tel(arr.getJSONObject(i).getString("shop_tel")==null?"":arr.getJSONObject(i).getString("shop_tel"));
				bean.setLongitude(arr.getJSONObject(i).getString("longitude")==null?"":arr.getJSONObject(i).getString("longitude"));
				bean.setLatitude(arr.getJSONObject(i).getString("latitude")==null?"":arr.getJSONObject(i).getString("latitude"));
				bean.setBak(arr.getJSONObject(i).getString("bak")==null?"":arr.getJSONObject(i).getString("bak"));
				//bean.setBak(arr.getJSONObject(i).getString("bak")==null?"":arr.getJSONObject(i).getString("bak"));
				list.add(bean);
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		return list;
	}

	@Override
	public Map<String,String> pareseJsonObject(String json) {
		Map<String,String> map=new HashMap<String,String>();
		try {
			JSONObject jsonObject = new JSONObject(json);
			if(jsonObject.getString("ret").equals("0")){
				map.put("ret", jsonObject.getString("ret"));
				return map;
			}
			map.put("ret", jsonObject.getString("ret"));
			map.put("module", jsonObject.getString("module"));
			map.put("version", jsonObject.getString("version"));
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return map;
	}

	@Override
	public Object pareseJsonBean(String json) {
		return null;
	}
	
}
